using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class upTank : MonoBehaviour
{

    public Material material_origin;
    public GameObject numnber;
    private Text numbers;
    private Text harm;
    private int num;
    private tank tank;
    //伤害倍率
    private double damageRatio = 1;
    void Start()
    {
        material_origin = new Material(gameObject.transform.GetComponent<Renderer>().material);
        numnber = GameObject.Find("intergral");
        numbers = numnber.transform.Find("number").GetComponent<Text>();
        harm = numnber.transform.Find("harm").GetComponent<Text>();
    }

    // Update is called once per frame
    void Update()
    {

    }
    private void OnMouseDown()
    {

        num = int.Parse(numbers.text);
        if (num >= 1500)
        {
            tank = GameObject.FindGameObjectWithTag("tank").GetComponent<tank>();
            tank.gameObject.GetComponent<tank>().speed += 20;
            tank.gameObject.GetComponent<tank>().harm += 20;
            damageRatio += 1;
            numbers.text = (num - 1500).ToString();
            harm.text = "伤害:"+damageRatio;
        }
    }
    private void OnMouseOver()
    //鼠标悬停时调用
    {
        gameObject.transform.GetComponent<Renderer>().material.color = Color.green;
    }
    private void OnMouseExit()
    //鼠标退出时调用
    {
        gameObject.transform.GetComponent<Renderer>().material.color = material_origin.color;
    }
}
